<template>
	<view
		v-if="merchantList.length"
		class="store-wrapper"
		:class="isStreet ? 'street-pad20' : ''"
	>
		<view
			class="store-item"
			:class="isStreet ? 'street-noPad' : ''"
			v-for="(item, index) in merchantList"
			:key="index"
		>
			<view @click="goShop(item.id)" class="head">
				<view class="left-wrapper">
					<view class="logo">
						<easy-loadimage
							:image-src="item.avatar"
							mode="scaleToFill"
						></easy-loadimage>
					</view>
					<view class="con-box">
						<view class="top-wrap">
							<view
								class="name store-name"
								:class="isStreet ? 'street-name' : ''"
							>
								<text class="mer_name line1">{{ item.name }}</text>
							</view>
						</view>
						<view class="star-box">
							<view class="star">
								<view
									class="stars"
									:class="isStreet ? 'street-active' : 'star-active'"
									:style="'width:' + (item.starLevel / 5) * 100 + '%'"
								></view>
							</view>
						</view>
						<view>
							<text v-if="item.isSelf" class="tag">{{
								$t(`page.store.selfSupport`)
							}}</text>
							<text class="tag">
								{{ $t($filters.merchantTypeFilter(item.typeId)) }}
							</text>
						</view>
					</view>
				</view>
				<view class="link" v-if="!isStreet" @click="goShop(item.id)">
					{{ $t(`进店`) }}
				</view>
			</view>
			<view class="pic-wrapper" :class="isStreet ? 'street-wrapper' : ''">
				<view
					v-for="(goods, goodsIndex) in item.proList"
					:key="goodsIndex"
					class="proList"
					@click="godDetail(goods)"
				>
					<view class="pic-item" :class="isStreet ? 'street-pic' : ''">
						<!-- <easy-loadimage :image-src="goods.image"></easy-loadimage> -->
						<GoodsImage :image-src="goods.image" />
						<view v-if="!isStreet" class="price">
							<statistic :value="goods.price" :currency="goods.currency" />
						</view>
					</view>
					<view v-if="isStreet" class="street-price street-price-left">
						<statistic :value="goods.price" :currency="goods.currency" />
					</view>
				</view>
			</view>
		</view>
		<!-- <view class='loadingicon acea-row row-center-wrapper' v-if='loading'>
			<text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
		</view> -->
		<!-- <view class='no-shop' v-if="!storeList.length && !loading">
			<view class='pictrue' style="margin: 0 auto;">
				<image src='/static/images/no-shop.png'></image>
				<text>暂无店铺，快去搜索其他店铺吧</text>
			</view>
		</view> -->
	</view>
</template>

<script>
import { goShopDetail } from "@/libs/order.js";
import mermorenImg from "@/static/images/mermoren.png";
import statistic from "@/components/statistic";
import GoodsImage from "@/components/easy-loadimage/goods-image.vue";
import { useAppStore } from "@/stores/app";
import Cache from "@/utils/cache.js";
const appStore = useAppStore();
export default {
	components: { statistic, GoodsImage },
	data() {
		return {
			skeletonShow: true,
			isShow: true,
			moren: mermorenImg,
		};
	},
	props: {
		merchantList: {
			type: Array,
			default: () => [],
		},
		isStreet: {
			type: Boolean,
			default: () => false,
		},
	},
	created() {
		Cache.clear("merchantType");
		console.log("xxx", Cache.get("merchantType"));
		appStore.MerTypeList();
	},
	methods: {
		godDetail(item) {
			goShopDetail(item);
		},
		menusTap(url) {
			uni.navigateTo({
				url,
			});
		},
		goShop(id) {
			uni.navigateTo({
				url: `/pages/merchant/home/index?id=${id}`,
			});
		},
	},
};
</script>

<style lang="scss" scoped>
.store-wrapper {
	//	margin-top: 328rpx;
}
.proList {
	padding-right: 22rpx;
}
.star-box {
	display: flex;
	align-items: center;
	margin: 15rpx 0;
	.star {
		position: relative;
		width: 111rpx;
		height: 19rpx;
		background: url("@/static/images/star.png");
		background-size: 111rpx 19rpx;
	}

	.stars {
		position: absolute;
		left: 0;
		top: 0;
		width: 111rpx;
		height: 19rpx;
		overflow: hidden;
	}
	.star-active {
		background: url(@/static/images/star_active.png);
		background-size: 111rpx 19rpx;
	}

	.num {
		color: $theme-color;
		font-size: 24rpx;
		margin-left: 10rpx;
	}
}
.street {
	&-name {
		color: #fff !important;
	}
	&-pad20 {
		padding: 0 20rpx;
	}
	&-backImage {
		padding: 24rpx 0 24rpx 20rpx;
		border-radius: 16rpx 16rpx 0rpx 0rpx;
	}
	&-noPad {
		padding: 0 !important;
		border-top-left-radius: 16rpx;
		border-top-right-radius: 16rpx;
	}
	&-pic {
		width: 208rpx !important;
		height: 208rpx !important;
		border-radius: 8rpx !important;
		overflow: hidden;
	}
	&-price {
		font-size: 30rpx;
		color: $theme-color;
		text-align: center;
		margin-top: 20rpx;
	}
	&-wrapper {
		//padding: 20rpx 25rpx !important;
		border-radius: 0 0 12rpx 12rpx;
	}
	&-active {
		background: url("@/static/images/star_active_purple.png");
		background-size: 111rpx 19rpx;
	}
}
.backImage {
	padding: 24rpx 0 24rpx 20rpx;
	border-radius: 16px 16px 0px 0px;
}

.store-item {
	margin-bottom: 30rpx;
	padding: 24rpx 30rpx 30rpx 30rpx;
	background-color: #fff;
	.head {
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		padding: 20rpx 10rpx;
		.left-wrapper {
			display: flex;
			align-items: center;

			.logo {
				width: 120rpx;
				height: 120rpx;
				border-radius: 50%;
				margin-bottom: 10rpx;
				overflow: hidden;

				image {
					width: 120rpx;
					height: 120rpx;
					border-radius: 50%;
					overflow: hidden;
				}
			}

			.con-box {
				margin-left: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				// height: 120rpx;
				.top-wrap {
					display: flex;
					justify-content: space-between;
					// width: 550rpx;
					flex: 1;
					// margin-bottom: 20rpx;
				}

				.name {
					font-size: 30rpx;
					color: #333;
					font-weight: bold;
					margin-bottom: 6rpx;
					.mer_name {
						// max-width: 400rpx;
						font-size: 32rpx;
						color: #0a0a0c;
					}
				}
			}
		}

		.link {
			width: 154rpx;
			padding: 0 15rpx;
			height: 50rpx;
			line-height: 50rpx;
			@include linear-gradient(theme);
			border-radius: 25rpx;
			text-align: center;
			color: #fff;
			font-size: 24rpx;
			flex: 0 0 1;
		}
	}

	.pic-wrapper {
		display: flex;
		padding: 20rpx 20rpx 25rpx;
		// justify-content: space-between;
		.pic-item {
			position: relative;
			width: 214rpx;
			height: 214rpx;
			overflow: hidden;
			border-radius: 16rpx;
			.easy-loadimage,
			image,
			uni-image {
				overflow: hidden;
				border-radius: 16rpx;
			}

			.price {
				position: absolute;
				right: 0;
				bottom: 0;
				height: 36rpx;
				padding: 0 10rpx;
				line-height: 36rpx;
				text-align: center;
				background: rgba(0, 0, 0, 0.5);
				border-radius: 16rpx 2rpx 16rpx 2rpx;
				color: #fff;
				font-size: 24rpx;

				text {
					font-size: 18rpx;
				}
			}

			&:nth-child(3n) {
				margin-right: 0;
			}
		}
	}
}
.store-name {
	display: flex;
}
.tag {
	color: #00785e;
	border-radius: 8rpx;
	background-color: #fff;
	padding: 4rpx 6rpx;
	border: 1rpx solid #00785e;
	font-size: 20rpx;
	margin-right: 10rpx;
}
.street-price-left {
	text-align: left;
	font-size: 28rpx;
	font-weight: 500;
}
</style>
